#!/bin/bash

#
# afauthtest -- by Dario Berzano <dario.berzano@gmail.com>
#
# Part of afdsmgrd -- http://afdsmgrd.googlecode.com/
#
# Tests if current proxy and AliEn token need renewal without modifying
# anything.
#

# Load library functions
source `dirname $0`/aflib

# Debug line, can be removed...
#echo "[`Datime`] $0 invoked with args: $@" >> /home/xrd/scratch/afmss.log

# The main function
function Main() {

  IsTokenExpiring
  if [ $? != 0 ]; then
    prn -w "Token is expiring"
  else
    prn -o "Token valid"
  fi

  IsProxyExpiring
  if [ $? != 0 ]; then
    prn -w "Proxy is expiring"
  else
    prn -o "Proxy valid"
  fi

}

Main $@
